﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace University.Workshop.Presenters.Users
{
    public class PresenterFirstStepForModifyUser
    {
        IFirstStepForModifyUser view;

        public PresenterFirstStepForModifyUser(IFirstStepForModifyUser view)
        {
            this.view = view;
        }

        public void UpdateData()
        {
            view.PersonId = view.UserToModify.Person.PersonId;
            view.PersonNames = view.UserToModify.Person.Names;
            view.PersonLastNames = view.UserToModify.Person.LastNames;
            view.PersonNewPhones = view.UserToModify.Person.Phone;
            ChargePhonesToList();
        }

        public void ChargePhonesToList()
        {
            view.PersonPhones = view.PersonNewPhones.Split(',').ToList().Where(x => x != string.Empty).ToList();
        }

        public void ChargeDataPerson()
        {
            //view.UserToModify.Person.PersonId = view.PersonId;
            view.UserToModify.Person.Names = view.PersonNames;
            view.UserToModify.Person.LastNames = view.PersonLastNames;
            view.UserToModify.Person.Phone = view.PersonNewPhones;
        }
    }
}
